<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>鼠标事件类型</title>
    <style>
        #box{
            width: 200px;
            height: 200px;
            background: yellow;
        }
        #child{
            width: 100px;
            height: 100px;
            background: red;           
        }
    </style>
</head>
<body>
    <button id="btn">click</button>
    <div id="box">mouse
        <div id="child">child</div>
    </div>
    <script>
        //鼠标事件
        btn.onclick = function(){
            console.log('鼠标单击')
        }
        btn.ondblclick = function(){
            console.log('鼠标双击')
        }
        btn.oncontextmenu = function(){
            console.log('鼠标右击')
        }
        box.onmousedown = function(){
            console.log('鼠标按下')
        }
        box.onmousemove = function(){
            console.log('鼠标移动')
        }
        box.onmouseup = function(){
            console.log('鼠标弹上')
        }
        //当移入孩子或者移出孩子都会触发
        box.onmouseover = function(){
            console.log('鼠标移入')
        }
        box.onmouseout = function(){
            console.log('鼠标移出')
        }
        //当移入孩子或者移出孩子不会触发
        box.onmouseenter = function(){
            console.log('鼠标移入')
        }
        box.onmouseleave = function(){
            console.log('鼠标移出')
        }
    </script>
</body>
</html>